package com.tensquare.friend.controller;

import entity.Result;
import entity.StatusCode;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 全局异常处理.
 *
 * @author 宫新程
 * @since 2019/3/20 16:50
 */
@ControllerAdvice
public class FriendHandlerException {

  @ExceptionHandler(value = Exception.class)
  @ResponseBody
  public Result error(Exception e) {
    e.printStackTrace();
    return new Result(false, StatusCode.ERROR, e.getMessage());
  }
}
